from Utilities.AutoGetOperator.selectPackage import get_func
Operator=get_func(r'Operators/OWAOperator/Operator.py','Operator')

class GOWA(Operator):
    def getResult(self,k):
        """
        GOWA 通过对OWA添加一个参数控制变量
        当k=1时，GOWA就是普通的OWA
        当k=0,GOWA算子成为几何OWA（OWG）算子
        当k=-1,聚合成为调和OWA（OWHA）算子
        当k=2,我们形成二次OWA（OWQA）算子
        """
        # 对数据进行简化
        data = self.data_list
        weight = self.weight_list
        # 对data 进行升序排列
        data = self.asc(data)
        # 分情况求结果
        if k != 0:
            # 获取初始值
            res = weight[0] * (data[0] ** k)
            for i in range(1,len(data)):
                res += weight[i] * (data[i] ** k)
            res = res ** (1 / k)
        else:
            # 当k=0时，结果就变成bj的wj次方的阶乘
            res = data[0] ** weight[0]
            for i in range(1,len(data)):
                res *= data[i] ** weight[i]

        return res


if __name__ == '__main__':
    data_list = [343.30,412.71,389.42,372.68,363.49,363.28]
    weight_list = [0.10,0.10,0.15,0.15,0.20,0.30]
    pa = GOWA(data_list)
    print(pa.getResult(1))
    print(pa.getResult(0))
    print(pa.getResult(-1))
    print(pa.getResult(2))